<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<div class="r_location">
	<i class="r_txtico"></i> 微信内容管理 &gt; 产品配置管理 &gt; 新增产品配置
</div>
<form id="add_func_form"  method="post" enctype="multipart/form-data" action="cms/product/add">
	<ul class="all_list">
		<li>
			<span class="all_title">产品名称：</span>
			<span>
				<input class="ui_input" id="productName" style="width:200px;"  name="productName" validator='{"label":"产品名称","maxLength":20}' >
			</span>
			<span class="all_title">产品价格：</span>
			<span>
				<input class="ui_input" id="price" style="width:200px;"  name="price" validator='{"label":"产品价格","maxLength":20,"isDigit":true}' >
			</span>
			
		</li>
		<li>
		<span class="all_title">产品类型：</span>
			<span>
				<select name="typeId" id="typeId" class="ui_option" style="width: 200px;height: 25px;">
					<option value="">请选择</option>
					<c:forEach items="${data}" var="type">
						<option value="${type.id}">${type.name}</option>
					</c:forEach>
				</select><font style="color: red;">*</font>
			</span>
			<span class="all_title">产品折扣：</span>
			<span>
				<input class="ui_input" id="discount" style="width:200px;"  name="discount" validator='{"label":"产品折扣","maxLength":20}' />(会员享受的折扣率必须是小数点)
			</span>
		</li>
		<li>
			<span class="all_title">购买人数：</span>
			<span>
				<input class="ui_input" id="number" style="width:200px;"  name="number" validator='{"label":"购买人数","maxLength":200,"isDigit":true}' >
			</span>
			<span class="all_title">最大购买人数：</span>
			<span>
				<input class="ui_input" id="maxNumber" style="width:200px;"  name="maxNumber" validator='{"label":"最大购买人数","maxLength":200,"isDigit":true}' >
			</span>
		</li>
		<li>
			<span class="all_title">时间：</span>
			<span>
				<input type="text" style="width: 200px;" id="departureTime" name="departureTime" class="ui_input datepicker Wdate" dateFormat="yyyy-MM-dd HH:mm:ss" group='{"group": {"startId":"departureTime", "endId":"departureTime","showNext": true}}' option='start-auto-end' /><font style="color: red;">*</font>
			</span>
			<span class="all_title">时长：</span>
			<span>
				<input class="ui_input" id="activityDuration" style="width:200px;"  name="activityDuration" validator='{"label":"活动时长","maxLength":20,"isDigit":true}' >
			</span>
			
		</li>
		<li>
			<span class="all_title">会员等级：</span>
			<span>
				<input class="ui_input" id="membershipGrade" style="width:200px;"  name="membershipGrade" validator='{"label":"会员等级","isDigit":true}' >
			</span>
			<span class="all_title">国家：</span>
			<span>
				<input class="ui_input" id="region" style="width:200px;"  name="region" validator='{"label":"国家","maxLength":20}' ><font style="color: red;">*</font>
			</span>
		</li>
		<li>
			<span class="all_title">课时：</span>
			<span>
				<input class="ui_input" id="classHour" style="width:200px;"  name="classHour" validator='{"label":"课时","maxLength":20}' >
			</span>
			<span class="all_title">月份：</span>
			<span>
				 <input class="ui_input" id="month" style="width:200px;"  name="month" validator='{"label":"活动月份","maxLength":20,"isDigit":true}' >
			</span>
		</li>
		<li>
			<span class="all_title">是否上架：</span>
			<span>
				 <input type="radio" name="stats" value="1" checked="checked"/>上架
				  <input type="radio" name="stats"  value="2"/>下架
			</span>
			<span class="all_title">是否返现：</span>
			<span>
				 <input type="radio" name="cashback" value="1" checked="checked"/>返现
				  <input type="radio" name="cashback"  value="0"/>不返现
			</span>
		</li>
		<li>
			<span class="all_title">是否推荐首页：</span>
			<span>
				 <input type="radio" name="recommend" value="1" checked="checked"/>推荐
				  <input type="radio" name="recommend"  value="2"/>不推荐
			</span>
			<span class="all_title">排序：</span>
			<span>
				 <input class="ui_input" id="sort" style="width:200px;"  name="sort" validator='{"label":"活动月份","maxLength":20,"isDigit":true}' >
			</span>
		</li>
		<li>
			<span class="all_title">产品小图片：</span>
			<span><input multiple type="file" id="minImageFile"  name="minImageFile"  onchange="previewProductImage(this)"></span>
		</li>
		<li>
			<span class="all_title"></span>
			<span id="preview"><img id="imghead" border=0 src="" width="100" height="70" /></span>
		</li>
		<li>
			<span class="all_title">产品展示图：</span>
			<span>
				<input multiple type="file"   name="productImageFile"  onchange="previewIcon(this)">
				<input multiple type="file"   name="productImageFile"  onchange="previewIcon(this)">
				<input multiple type="file"   name="productImageFile"  onchange="previewIcon(this)">
				<input multiple type="file"   name="productImageFile"  onchange="previewIcon(this)">
			</span>
		</li>
		<!-- <li>
			<span class="all_title"></span>
			<span id="previewIcon"><img id="iconhead" border=0 src="" width="100" height="70" /></span>
		</li> -->
		<li>
			<li class="editor"><span class="all_title">产品描述</span> <span>
				<textarea id="content" name="remark"
					class="xheditor {tools:'FontSize,FontColor,Bold,Italic,Underline,Strikethrough,Fullscreen,Align,About',skin:'default',height:'300'}"
					rows="8" cols="80" style="width: 70%">
				</textarea> <span id="contentError"></span>
		</span></li>
		</li>
		<li>
			<span class="all_title"></span>
			<span>
				<input type="button" id="save_button" value="提 交" class="submit_btn m-r15 submitBtn">
			</span>
		</li>
	</ul>
</form>
<script type="text/javascript">
	$(function(){
		$.datepicker();
		$('#content').xheditor();
		$('#reset_button').click(function() {
			$('#content').val('');
		});

		function showDialog(url, options) {
			myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
			$.post(url, options.param, function(data) {
				myDialog.content(data);
			});
		}
		$("#add_func_form").validator({},{
			callback:function(result){
				 // 校验相关的图片是否为空
				/*if ($('#upload_table input[name="pic"]').filter('[value!=""]').size() == 0) {
					art.dialog({icon: 'error',content: '相关的图片不能为空',lock:true});
					return false;
				}
				
				// 校验图片后缀
				var pattern = /\.jpg$|\.jpeg$|\.png$/i;
				var validate = true;
				$('#upload_table input[name="pic"]').filter('[value!=""]').each(function(){
					if (!pattern.test($(this).val())) {
						validate = false;
						return false;
					}
				});				
				if (!validate) {
					art.dialog({icon: 'error',content: '图片格式不正确, 只能上传图片格式: .jpg, .jpeg, .png',lock:true});
					return false;
				} */
				
				if(!$('#typeId').val()){
					alert("产品类型不能为空");
					return false;
				}
				if(!$('#departureTime').val()){
					alert("活动时间不能为空");
					return false;
				}
				if (!$('#content').val()) {
					$('#contentError').html('内容不能为空!').addClass('frame_error');
					return false;
				} else {
					$('#contentError').html('').removeClass('frame_error');
				}
				
				$("#add_func_form").ajaxSubmit(function(data){
					if (data.success == 'succeed') {
						to_page('/cms/product/view/page');
					} else {
						art.dialog({icon: 'error',content: data.message,lock:true});
					}
				});
			}
		});
	});
</script>